package com.hemerasolutions.v2trainer.model.users;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

import com.hemerasolutions.v2trainer.model.base.BaseModel;
import com.hemerasolutions.v2trainer.model.interfaces.AgreementHolderInterface;
import com.hemerasolutions.v2trainer.model.multimedia.Photo;
import com.hemerasolutions.v2trainer.model.others.Theme;

@Entity
public class Admin extends BaseModel implements AgreementHolderInterface  {
 
	private static final long serialVersionUID = 1L;

    @Column(length = 20)
    private String firstName;
    
    @Column(length = 50)
    private String lastName;
    
    @OneToOne(cascade=CascadeType.ALL,orphanRemoval=true)
    private User user;

    @OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY,orphanRemoval=true)
    private Photo photo;   	 

    @ManyToOne(fetch=FetchType.LAZY)
    private Theme theme;

	public Admin() {
		super();

		this.user 		= new User();
		this.theme	 	= new Theme();
		this.user.setUserType(User.USERTYPE_ADMIN);
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getFirstName() {
		return firstName;
	}

	public User getUser() {
		return user;
	}

	public Theme getTheme() {
		return theme;
	}

	public Photo getPhoto() {
		return photo;
	}

	public void setFirstName(String name) {
		this.firstName = name;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public void setTheme(Theme theme) {
		this.theme = theme;
	}

	public void setPhoto(Photo photo) {
		this.photo = photo;
	}
	
	
	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((lastName == null) ? 0 : lastName.hashCode());
		result = prime * result + ((photo == null) ? 0 : photo.hashCode());
		result = prime * result + ((theme == null) ? 0 : theme.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Admin other = (Admin) obj;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		if (photo == null) {
			if (other.photo != null)
				return false;
		} else if (!photo.equals(other.photo))
			return false;
		if (theme == null) {
			if (other.theme != null)
				return false;
		} else if (!theme.equals(other.theme))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Admin [id=" + id + ", firstName=" + firstName + ", lastName="
				+ lastName + ", user=" + user + ", theme=" + theme + ", photo="
				+ photo + "]";
	}

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Photo getLogo() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Photo getWideLogo() {
		// TODO Auto-generated method stub
		return null;
	}

	
	
}
 
